﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Controls;
using OpenExpressApp.Editors;

namespace OpenExpressApp.Module.WPF.Editors.TreeColumn
{
    public class MemoTreeColumn : TreeColumn
    {
        private MemoPropertyEditor _editor;

        public MemoTreeColumn(BusinessObjectPropertyInfo info, IListObjectView view)
            : base(info, view)
        {
            this._editor = new MemoPropertyEditor(this.PropertyInfo, this.View);
        }

        public override IWPFPropertyEditor Editor
        {
            get
            {
                return this._editor;
            }
        }

        /// <summary>
        /// 设定宽度和高度限制
        /// </summary>
        /// <returns></returns>
        protected override FrameworkElement GenerateElementInBorder()
        {
            FrameworkElement fe = base.GenerateElementInBorder();
            fe.Height = EditorConst.MemoEditorHeight;
            fe.Width = EditorConst.MemoEditorWidth;
            return fe;
        }

        protected override FrameworkElementFactory GenerateElementFactoryInBorder()
        {
            FrameworkElementFactory fef = base.GenerateElementFactoryInBorder();
            fef.SetValue(TextBlock.HeightProperty, EditorConst.MemoEditorHeight);
            fef.SetValue(TextBlock.WidthProperty, EditorConst.MemoEditorWidth);
            return fef;
        }

        public override FrameworkElement GenerateEditingFrameworkElement()
        {
            FrameworkElement fe = base.GenerateEditingFrameworkElement();
            fe.Height = EditorConst.MemoEditorHeight;
            fe.Width = EditorConst.MemoEditorWidth;
            return fe;
        }
    }
}